﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    public class KaoGuanModel
    {
        private int _Sec;
        [DataMember]
        public int Sec
        {
            get { return _Sec; }
            set { _Sec = value; }
        }
        private bool isselected = false;
        [DataMember]
        public bool IsSelected
        {
            get { return isselected; }
            set { isselected = value; }
        }
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private string _YongRenDanWei;
        [DataMember]
        public string YongRenDanWei
        {
            get { return _YongRenDanWei; }
            set { _YongRenDanWei = value; }
        }
        private string _Name;
        [DataMember]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        private string _CardNo;
        [DataMember]
        public string CardNo
        {
            get { return _CardNo; }
            set { _CardNo = value; }
        }
        private string _GongZuoDanWei;
        [DataMember]
        public string GongZuoDanWei
        {
            get { return _GongZuoDanWei; }
            set { _GongZuoDanWei = value; }
        }
        private string _ZhiWuZhiCheng;
        [DataMember]
        public string ZhiWuZhiCheng
        {
            get { return _ZhiWuZhiCheng; }
            set { _ZhiWuZhiCheng = value; }
        }
        private string _LianXiFangShi;
        [DataMember]
        public string LianXiFangShi
        {
            get { return _LianXiFangShi; }
            set { _LianXiFangShi = value; }
        }
        private bool _IsKaoGuanZheng;
        [DataMember]
        public bool IsKaoGuanZheng
        {
            get { return _IsKaoGuanZheng; }
            set { _IsKaoGuanZheng = value; }
        }
        private string _Memo;
        [DataMember]
        public string Memo
        {
            get { return _Memo; }
            set { _Memo = value; }
        }
        private string _EMail;
        [DataMember]
        public string EMail
        {
            get { return _EMail; }
            set { _EMail = value; }
        }
        private string _IsKaoGuanZhengS;
        [DataMember]
        public string IsKaoGuanZhengS
        {
            get { return _IsKaoGuanZhengS; }
            set { _IsKaoGuanZhengS = value; }
        }
        private DateTime? _RiQi;
        [DataMember]
        public DateTime? RiQi
        {
            get { return _RiQi; }
            set { _RiQi = value; }
        }


        private int _KaoGuanID;
        [DataMember]
        public int KaoGuanID
        {
            get { return _KaoGuanID; }
            set { _KaoGuanID = value; }
        }

        private int _Year;
        [DataMember]
        public int Year
        {
            get { return _Year; }
            set { _Year = value; }
        }
        private string _XBType;
        [DataMember]
        public string XBType
        {
            get { return _XBType; }
            set { _XBType = value; }
        }
        private string _KGType;
        [DataMember]
        public string KGType
        {
            get { return _KGType; }
            set { _KGType = value; }
        }

        private string _Zu;
        [DataMember]
        public string Zu
        {
            get { return _Zu; }
            set { _Zu = value; }
        }

        private string _Creator;
        [DataMember]
        public string Creator
        {
            get { return _Creator; }
            set { _Creator = value; }
        }

        private DateTime? _CreateTime;
        [DataMember]
        public DateTime? CreateTime
        {
            get { return _CreateTime; }
            set { _CreateTime = value; }
        }

        private string _Type;
        [DataMember]
        public string Type
        {
            get { return _Type; }
            set { _Type = value; }
        }

        private int _OrgID;
        [DataMember]
        public int OrgID
        {
            get { return _OrgID; }
            set { _OrgID = value; }
        }

        private bool _IsShangBao;
        [DataMember]
        public bool IsShangBao
        {
            get { return _IsShangBao; }
            set { _IsShangBao = value; }
        }
        private string _IsShangBaoS;
        [DataMember]
        public string IsShangBaoS
        {
            get { return _IsShangBaoS; }
            set { _IsShangBaoS = value; }
        }


        private string _CSGW;
        [DataMember]
        public string CSGW
        {
            get { return _CSGW; }
            set { _CSGW = value; }
        }
        private string _XL;
        [DataMember]
        public string XL
        {
            get { return _XL; }
            set { _XL = value; }
        }
        private string _ZWLB;
        [DataMember]
        public string ZWLB
        {
            get { return _ZWLB; }
            set { _ZWLB = value; }
        }
        private string _XZJB;
        [DataMember]
        public string XZJB
        {
            get { return _XZJB; }
            set { _XZJB = value; }
        }
        private string _SZDW;
        [DataMember]
        public string SZDW
        {
            get { return _SZDW; }
            set { _SZDW = value; }
        }
        private string _Iszl;
        [DataMember]
        public string Iszl
        {
            get { return _Iszl; }
            set { _Iszl = value; }
        }
        
        public static KaoGuanModel FillEntity(DataRow dr)
        {
            KaoGuanModel right = new KaoGuanModel();
            if (dr.Table != null && dr.Table.Columns.Contains("Sec")) right.Sec = Convert.ToInt32(dr["Sec"]);
            right.ID = (int)dr["ID"];
            if (dr.Table != null && dr.Table.Columns.Contains("OrgID")) if (!string.IsNullOrEmpty(dr["OrgID"].ToString())) right.OrgID = (int)dr["OrgID"];
            if (!string.IsNullOrEmpty(dr["IsKaoGuanZheng"].ToString()))
            {
                right.IsKaoGuanZheng = (bool)dr["IsKaoGuanZheng"];
                if (dr["IsKaoGuanZheng"].ToString() == "False") right.IsKaoGuanZhengS = "否";
                else right.IsKaoGuanZhengS = "是";
            }
            if (dr.Table != null && dr.Table.Columns.Contains("IsShangBao"))
            if (!string.IsNullOrEmpty(dr["IsShangBao"].ToString()))
            {
                right.IsShangBao = (bool)dr["IsShangBao"];
                if (dr["IsShangBao"].ToString() == "False") right.IsShangBaoS = "否";
                else right.IsShangBaoS = "是";
            }
            right.YongRenDanWei = dr["YongRenDanWei"] as string;
            right.Name = dr["Name"] as string;
            right.CardNo = dr["CardNo"] as string;
            right.GongZuoDanWei = dr["GongZuoDanWei"].ToString();
            right.ZhiWuZhiCheng = dr["ZhiWuZhiCheng"].ToString();
            right.LianXiFangShi = dr["LianXiFangShi"].ToString();
            right.Memo = dr["Memo"] as string;
            right.EMail = dr["EMail"] as string;
            right.KaoGuanID = (int)dr["KaoGuanID"];
            right.Year = (int)dr["Year"];
            right.XBType = dr["XBType"] as string;
            right.KGType = dr["KGType"] as string;
            right.Creator = dr["Creator"] as string;
            right.CreateTime = string.IsNullOrEmpty(dr["CreateTime"].ToString()) ? null : (DateTime?)dr["CreateTime"];
            if(!string.IsNullOrEmpty(dr["RiQi"].ToString()) && Convert.ToDateTime(dr["RiQi"].ToString()) != Convert.ToDateTime("1900-01-01")) 
                right.RiQi = (DateTime?)dr["RiQi"];
            if (dr.Table != null && dr.Table.Columns.Contains("Type")) right.Type = dr["Type"] as string;

            right.CSGW = dr["CSGW"] as string;
            right.XL = dr["XL"] as string;
            right.ZWLB = dr["ZWLB"] as string;
            right.XZJB = dr["XZJB"] as string;
            right.SZDW = dr["SZDW"] as string;

            if (dr.Table != null && dr.Table.Columns.Contains("Iszl"))
                right.Iszl = dr["Iszl"] as string;
            return right;
        }
    }
}
